import time

from library import vk1640b

# 一共8列
MAX_COLUMNS = 8
# 爱心图案
I_TABLE = [0x00, 0x1C, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x00]
LOVE_TABLE = [0x00, 0x66, 0xFF, 0xFF, 0x7E, 0x3C, 0x18, 0x00]
YOU_TABLE = [0x00, 0x22, 0x14, 0x08, 0x08, 0x08, 0x08, 0x00]


def display(data):
    for row in range(MAX_COLUMNS):
        if data[row] != 0:
            vk1640b.send_fixed_address_data([(row, data[row])])


if __name__ == '__main__':
    vk1640b.init()
    vk1640b.clear_display(MAX_COLUMNS)
    try:
        while True:
            display(I_TABLE)
            time.sleep(2)
            vk1640b.clear_display(MAX_COLUMNS)
            display(LOVE_TABLE)
            time.sleep(2)
            vk1640b.clear_display(MAX_COLUMNS)
            display(YOU_TABLE)
            time.sleep(2)
            vk1640b.clear_display(MAX_COLUMNS)
    finally:
        vk1640b.clear_display(MAX_COLUMNS)
        vk1640b.cleanup()
